const typeModel = require('../models/types.model')
class TypeService {
  types = typeModel
  findAll () {
    return this.types.find({ deleted: false })
  }
  addOne (data) {
    return this.types.create(data)
  }
  findOne (id) {
    return this.types.find({ deleted: false, _id: id })
  }
  updateOne (id, data) {
    return this.types.findOneAndUpdate({ _id: id }, data)
  }
  deleteOne (id) {
    return this.types.findOneAndRemove({ _id: id })
  }
}

module.exports = TypeService